<style>
    body,html{
        background-color: #F9F9F9;
    }
</style>
<script>
    window.onload = function(){


        var form = new xhForm($('#xh_form'));
        form.parse();
        //提交按钮处理事件
        $(".form-datetime").datetimepicker({format:"yyyy-mm-dd hh:ii:ss",language:"zh-CN",autoclose:true});

        $('[name=expressTarget]').change(function () {
            var val = $(this).val();
            if(val == 1){
                var str = '<tr>' +
                    '                <td style="width: 75px;"><label>承运人</label></td>' +
                    '                <td><input type="text" name="deliverName" class="form-control" must="true"></td>' +
                    '            </tr>' +
                    '            <tr>' +
                    '                <td><label>运单号</label></td>' +
                    '                <td colspan="3"><input type="text" name="trackingNo" class="form-control" must="true"></td>' +
                    '            </tr>' ;

                $('#xh_form').find('tr:last').after(str);
                form.bindRequired($('#bt_modal_confirm',window.top.document));
            }else {
                $('[name=deliverName],[name=trackingNo]').parent().parent().remove();
                $('#bt_modal_confirm',window.top.document).removeClass('disabled')
            }
//            form.bindRequired($('#bt_modal_confirm',window.top.document));
        });
        form.bindRequired( $('#bt_modal_confirm',window.top.document));
        $('#bt_modal_confirm',window.top.document).click(function () {
            var trackingNo = $('[name=trackingNo]').val();
            if(/[\u4e00-\u9fa5]+/g.test(trackingNo)){
                window.top.xhTop.showError('运单号格式不正确');
                xhExtra.setBtnNormal($('#bt_modal_confirm' , window.top.document));
                return false;
            }
            form.submit('order/deliverTablet',{},function (res) {
                window.top.xhTop.showSuccess(res.msg);
                window.top.xhTop.getActiveFrame()['tabletFrame'].obj.dataGrid.reload();
                window.top.xhTop.closeModal();
            });
        });
    }
    // /**
    //  * Date扩展
    //  * @param format
    //  * @returns {*}
    //  */
    // Date.prototype.format =function(format)
    // {
    //     var o = {
    //         "M+" : this.getMonth()+1, //month
    //         "d+" : this.getDate(), //day
    //         "h+" : this.getHours(), //hour
    //         "m+" : this.getMinutes(), //minute
    //         "s+" : this.getSeconds(), //second
    //         "q+" : Math.floor((this.getMonth()+3)/3), //quarter
    //         "S" : this.getMilliseconds() //millisecond
    //     }
    //     if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
    //         (this.getFullYear()+"").substr(4- RegExp.$1.length));
    //     for(var k in o)if(new RegExp("("+ k +")").test(format))
    //         format = format.replace(RegExp.$1,
    //             RegExp.$1.length==1? o[k] :
    //                 ("00"+ o[k]).substr((""+ o[k]).length));
    //     return format;
    // }
</script>

<form id="xh_form" class="xh-form"  method="post"    style="margin-left: 20px;">
    <div class="xh-area-form">
        <table >
            <tr>
                <td style="width: 75px;"><label>选择类型</label></td>
                <td style="width: 200px;">
                    <select name="expressTarget">
                        <option value="1" selected>个人</option>
                        <option value="2">学校</option>
                    </select>
                    <input  type="hidden" name="orderNo" value="{{ no }}">
                </td>
                <td></td>
                <td style="width: 150px;"></td>
                {#<td style="width: 75px;"><label>发单日期</label></td>#}
                {#<td><input type="text" name="deliverDate" class="form-datetime" must="true"></td>#}
            </tr>
            <tr>
                <td style="width: 75px;"><label>承运人</label></td>
                <td><input type="text" name="deliverName" must="true"></td>
            </tr>
            <tr>
                <td><label>运单号</label></td>
                <td colspan="3"><input type="text" name="trackingNo" must="true"></td>
            </tr>

        </table>
    </div>
</form>